<template>
  <div class="integral-wrap">
    <van-nav-bar title="积分商城" @click-right="getSearch">
      <van-icon name="search" slot="right" />
    </van-nav-bar>
    <van-tabs v-model="active" swipeable>
      <van-tab
        v-for="(item, index) in category"
        :title="item.title"
        :key="index"
      >
      </van-tab>
    </van-tabs>
    <div class="goods-list dg">
      <div
        class="goods shadow text-center"
        v-for="(item, index) in goodsData"
        @click="getProduct(item)"
        :key="index"
      >
        <div class="avatar">
          <img :src="item.avatar" />
        </div>
        <div class="info">
          <span class="van-multi-ellipsis--l2">{{ item.title }}</span>
          <p class="text-gold">{{ item.integral | integral }}</p>
          <p class="text-gold">+{{ 2323 }}元</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { integralGoods } from "@/api";
export default {
  name: "Integral",
  data() {
    return {
      active: 0,
      category: null,
      goodsData: null
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      integralGoods()
        .then(res => {
          this.category = res.data;
          this.goodsData = res.data[0].good;
        })
        .catch(err => {
          console.log(err);
        });
    },
    getProduct(item) {
      console.log(item);
      console.log(111);

      // this.$router.
    },
    getSearch() {}
  }
};
</script>
<style lang="scss" scoped>
.integral-wrap {
  .goods-list {
    width: 100%;
    grid-template-columns: 1fr 1fr 1fr;
    .goods {
      margin: 0.25 * $size;
      padding: 0.25 * $size;
      .avatar {
        width: 8.6154 * $size;
        height: 8.6154 * $size;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>
